package com.example.app.pages.main.home.addNew.addRecord.MyModalBottomSheetRelationPicker

import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import com.example.app.components.MyButton.MyTextButton
import com.example.app.components.MyIcon.MyEditIcon
import com.example.app.components.MyIcon.MyNavigationIcon
import com.example.app.components.MyText.MyText
import com.example.app.components.MyTopBar.MyTopBar
import com.example.app.pages.main.home.me.viewModel.AddNewViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ManageRelationListTopBar(
        addNewViewModel: AddNewViewModel,
        isEdit: MutableState<Boolean>,
        dismiss: () -> Unit
) {
    var _isEdit by remember {
        isEdit
    }
    MyTopBar(title = {
        MyText(text = "成员管理")
    },
        windowInsets = WindowInsets(
            0,
            0,
            0,
            0
        ),
        actions = {
            if (addNewViewModel.checkBoxListIncomeRelationPeopleItemList.size > 0) {
                if (!_isEdit) {
                    MyEditIcon(onClick = {
                        _isEdit = true
                    })
                } else {
                    MyTextButton(onClick = {
                        _isEdit = false
                    }) {
                        MyText(
                            text = "完成",
                            color = MaterialTheme.colorScheme.primary
                        )
                    }
                }
            }
        },
        navigationIcon = {
            MyNavigationIcon(onClick = dismiss)
        })
}